package com.example.beautymakeup.dao;

import com.example.beautymakeup.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {

//    获取用户的信息
    @Select("select * from user where openId = #{openId};")
    User getByOpenId(String openId);

    @Select("select * from user where uid = #{uid} and status = 0 ;")
    User getById(String uid);

//    新增用户
    @Insert("insert into user (openId, userName, userImage) VALUES (#{openId},#{userName},#{userImage});")
    int save(User user);

//    修改用户信息
    @Update("update user set userName = #{userName} ,userImage = #{userImage} where uid = #{uid};")
    int updateUser(User user);

//    查询所有用户,分页
    @Select("select * from user limit #{page} ,#{size};")
    List<User> getUserAll(@Param("page") int page,@Param("size") int size);

//    查询所有用户数量
    @Select("select count(*) from user;")
    int getUserAllTotal();

//    封禁或解禁账号
    @Update("UPDATE user SET status = #{status} WHERE uid = #{uid};")
    int banByUId(User user);
}
